import { config } from '../../config/index';
import { request } from '../../utils/request';

/**
 * 获取单个点评详细信息
 * @param {*} ID 
 * @returns 
 */
function mockFetchReview(ID = 0, isDetails = false) {
  const { delay } = require('../_utils/delay');
  const { genReview } = require('../../model/review');
  return delay().then(() => genReview(ID, isDetails) );
}

/**
 * 获取单个点评详细信息
 * @param {*} ID 
 * @returns 
 */
export function fetchReview(ID = 0, isDetails = false) {
  if (config.useMock) {
    return mockFetchReview(ID, isDetails);
  } 
  const query_id = ID;
  const user_id = wx.getStorageSync('user_id');
  return request(`reviews/${query_id}&${user_id}`).then((res) => {
    return res;
  });
}

export function updateLiker(data) {
  return request('revievs/update/liker', data, 'POST').then((res) => {
    return res;
  })
}

export function addLook(reviews_id) {
  return request(`reviews/look/${reviews_id}`).then((res) => {
    return res;
  })
}